﻿/*
 * 泛依低代码开发平台JS代码
 * fanyeyong
 * fyysoft@126.com
 * 2021-10-25 10:03:00
 * Copyright (c) 2015-2021 泛依软件
 */
(function () {
    if (window.queryhash) {
        return;
    }
    window.queryhash = function () {
    };
    queryhash.prototype = {
        HasHash: function () {
            if (location.hash === '' || location.hash.length == 0) {
                return false;
            }

            return true;
        },
        parseFromLocation: function () {
            if (location.hash === '' || location.hash.length == 0) {
                return;
            }

            var properties = location.hash.substr().trim('#', 'left').split('/');
            var index = 0;
            for (var p in this) {
                if (!this.hasOwnProperty(p) || typeof this[p] != 'string') {
                    continue;
                }
                if (index < properties.length) {
                    this[p] = properties[index];
                    if (this[p] === '-') {
                        this[p] = '';
                    }
                }
                index++;
            }
        },
        parseFromLocation2: function () {
            if (location.hash === '' || location.hash.length == 0) {
                return;
            }

            var properties = location.hash.substr().trim('#', 'left').split('/');
            return properties;
        },
        updateLocation: function () {
            var properties = [];
            for (var p in this) {
                var value = this[p];
                if (!this.hasOwnProperty(p) || typeof this[p] != 'string') {
                    continue;
                }

                properties.push(value);
            }

            this.updateLocation2(properties);
            //if (!window.location.origin) {
            //    window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
            //}

            //var url = location.origin + location.pathname + location.search + "#" + properties.join('/');
            //location.replace(url);
            //if ($.browser.webkit == false) {
            //    window.location.hash = location.hash;
            //} else {
            //    window.location.href = location.hash;
            //}
        },
        updateLocation2: function (properties) {
            if (!window.location.origin) {
                window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
            }

            var url = location.origin + location.pathname + location.search + "#" + properties.join('/');
            location.replace(url);
            if (location.hash == '') {
                return;
            }

            if ($.browser.webkit == false) {
                window.location.hash = location.hash;
            } else {
                window.location.href = location.hash;
            }
        }
    };
})();

String.prototype.trim = function (char, type) {
    if (char) {
        if (type == 'left') {
            return this.replace(new RegExp('^\\' + char + '+', 'g'), '');
        } else if (type == 'right') {
            return this.replace(new RegExp('\\' + char + '+$', 'g'), '');
        }
        return this.replace(new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), '');
    }
    return this.replace(/^\s+|\s+$/g, '');
};

(function () {
    window.tbl_queryhash = function () {
        queryhash.constructor.call(this);
        this.type = '1';
        this.tbls = '';
        this.keyword = '';
    };

    tbl_queryhash.constructor = tbl_queryhash;
    tbl_queryhash.prototype = new queryhash();
})(); 